package rank1400;

import java.util.*;

/**
 * 2451. 差值数组不同的字符串
 */
public class No2451 {
    public String oddString(String[] words) {
        int n = words[0].length();
        HashMap<String, List<String>> map = new HashMap<>();
        for (String word : words) {
            char[] differences = new char[n - 1];
            for (int i = 0; i < n - 1; i++) {
                differences[i] = (char) (word.charAt(i) - word.charAt(i + 1));
            }
            String key = new String(differences);
            List<String> list = map.getOrDefault(key, new ArrayList<>());
            list.add(word);
            map.put(key, list);
        }
        for (Map.Entry<String, List<String>> entry : map.entrySet()) {
            if (entry.getValue().size() == 1) return entry.getValue().get(0);
        }
        return null;
    }
}
